package com.lwc.cfdns.pojo.bo.monitor;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lwc.cfdns.pojo.bo.AbstractPageQuery;
import com.lwc.cfdns.pojo.entity.SystemLogininfor;
import com.lwc.cfdns.pojo.entity.SystemOperLog;
import com.lwc.cfdns.utils.ConvertUtils;
import com.lwc.cfdns.utils.StringUtils;
import lombok.Data;

/**
 * 操作日志查询表单
 *
 * @author luwc
 * @title OperLogBO
 * @description
 * @time 2023/8/2 21:53:48
 * @version: 1.0
 */
@Data
public class OperLogBO extends AbstractPageQuery<SystemOperLog> {
    private String title;
    private String operName;
    private String businessType;// 业务类型（0其它 1新增 2修改 3删除）
    private String status;
    private String stime;
    private String etime;

    @Override
    public LambdaQueryWrapper<SystemOperLog> toQueryWrapper() {
        LambdaQueryWrapper<SystemOperLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(getTitle())) {
            lambdaQueryWrapper.like(SystemOperLog::getTitle, getTitle());
        }
        if (StringUtils.isNotEmpty(getBusinessType())) {
            lambdaQueryWrapper.eq(SystemOperLog::getBusinessType, getBusinessType());
        }
        if (StringUtils.isNotEmpty(getStatus())) {
            lambdaQueryWrapper.eq(SystemOperLog::getStatus, getStatus());
        }
        // 日期模式
        if (StringUtils.isNotEmpty(getStime())) {
            lambdaQueryWrapper.ge(SystemOperLog::getOperTime, getStime());
        }
        if (StringUtils.isNotEmpty(getEtime())) {
            lambdaQueryWrapper.le(SystemOperLog::getOperTime, getEtime());
        }
        lambdaQueryWrapper.orderByDesc(SystemOperLog::getId);
        return lambdaQueryWrapper;
    }
}
